#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2020/08/14
# @Author   :Changshu
# @File     :practice_38.py
# 给定一个正整数 n（1 ≤ n ≤ 30），输出外观数列的第 n 项。


def countAndSay(n:int)->str:
	if n==1:
		return '1'
	temp=countAndSay(n-1)
	result=''
	c='0'
	count=0
	for i in range(0,len(temp)):
		if i==0:
			c=temp[i]
			count=1
		else:
			if temp[i]==c:
				count+=1
			else:
				result+=str(count)
				result+=c
				c=temp[i]
				count=1
	result += str(count)
	result += c
	return result

if __name__=='__main__':
	n=12
	print(countAndSay(n))

